package cn.tedu.csmall.stock.webapi.consumer;

import cn.tedu.csmall.stock.webapi.config.RabbitMQConfig;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
//去监听指定的stock_queue队列
@RabbitListener(queues = {RabbitMQConfig.STOCK_QUEUE})
public class RabbitMQConsumer {

    //如果监听到数据了，那么就指定一个方法去处理
    //方法中参数列表中声明要转换的类型：从队列中接收到的数据就会直接转换成指定的类型
    @RabbitHandler
    public void process(LocalDateTime now){
        System.out.println("接收到消息:"+now);
    }
}
